package com.example.venue_reservation_service.converter;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;

public class ListConverter {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    // List<String> 转 String
    public static String listToString(List<String> list) throws Exception {
        return objectMapper.writeValueAsString(list);
    }

    // String 转回 List<String>
    public static List<String> stringToList(String str) throws Exception {
        return objectMapper.readValue(str, objectMapper.getTypeFactory()
                .constructCollectionType(List.class, String.class));
    }
}
